GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a7d869...2b73a7 )
by Stefano
02:46
created

raml2html.then-0   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
nc 2
dl 0
loc 33
rs 8.8571
nop 1
1
var raml2html = require('raml2html');
2
var chalk = require('chalk');
3
var emoji = require('node-emoji');
4
var fs = require('fs');
5
var path = require('path');
6
var http = require('http');
7
var url = require('url');
8
var childProcess = require('child_process');
9
10
scriptPath = 'scripts/js/api.server.js';
0 ignored issues
show
Bug introduced by
The variable scriptPath seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.scriptPath.
Loading history...
11
12
var options = {
13
  env: process.env
14
};
15
16
var childProcessInstance = childProcess.fork(scriptPath, options);
17
18
// listen for errors as they may prevent the exit event from firing
19
childProcessInstance.on('error', function (err) {
20
  if ( err ){
21
    process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore server documentazione API (raml)\n")));
22
    process.stderr.write(chalk.red(err+"\n"));
23
    process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
24
  }
25
});
26
27
var enviroment = process.env.npm_package_config_enviroment;
28
29
var apiDir = path.join(__dirname, '../../api/');
30
31
process.stdout.write(chalk.gray(emoji.emojify('[  ] Generazione Documentazione API (' + enviroment + ") from "+ ramlFile +"\n")));
0 ignored issues
show
Bug introduced by
The variable ramlFile seems to be never initialized.
Loading history...
32
33
var ramlFile = path.join(__dirname, '../../api/api.raml');
34
35
var ramlHtml = path.join(__dirname, '../../api/api-generated.html');
36
37
var configWithCustomTemplates = raml2html.getDefaultConfig('template.nunjucks', path.normalize(apiDir + '/template') );
38
39
// source can either be a filename, url, file contents (string) or parsed RAML object
40
raml2html.render(ramlFile, configWithCustomTemplates).then(function(result) {
41
  // Save the result to a file or do something else with the result
42
  // api-generated.html
43
  //
44
  // console.log(result);
45
46
  fs.writeFile(ramlHtml, result, function(err) {
47
      if(err) {
48
        process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore generazione documentazione API (raml)\n")));
49
        process.stderr.write(chalk.red(err+"\n"));
50
        process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
51
      }
52
53
      process.stdout.write(chalk.gray(emoji.emojify('[  ] Server must stop '+"\n")));
54
55
      var options = {
56
        host: 'localhost',
57
        port: 9999,
58
        path: '/end',
59
        method: 'GET'
60
      };
61
62
      var reqCloseServer = http.request(options, function(res) {
63
        statusCode = `${res.statusCode}`;
0 ignored issues
show
Bug introduced by
The variable statusCode seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.statusCode.
Loading history...
64
        process.stdout.write(chalk.gray(emoji.emojify('[  ] Response '+ statusCode +"\n")));
65
66
        process.stdout.write(chalk.bgGreen.black(emoji.emojify('[:heavy_check_mark: ] API Documentation created!' + "\n")));
67
      });
68
69
      reqCloseServer.on('error', (e) => {
70
        error = `${e.message}`;
0 ignored issues
show
Bug introduced by
The variable error seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.error.
Loading history...
71
        process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore generazione documentazione API (raml)\n")));
72
        process.stderr.write(chalk.red(error+"\n"));
73
        process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
74
      });
75
76
      reqCloseServer.end();
77
78
  });
79
80
}, function(error) {
81
  console.log(error);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
82
  process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore generazione documentazione API (raml)\n")));
83
  process.stderr.write(chalk.red(error+"\n"));
84
  process.exit(1);
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
85
});
86